// pages/Topselling/Topselling.js
var that 
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tolist:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (t) {
    getApp().page.onLoad(this, t),  that = this;
    that.hot_list()
  },
  hot_list:function(e){
    getApp().request({
      url:  getApp().api.default.hot_goods_list,
      data:{
        page:1
      },
      success: function (t) {
        if(t.code == 0){
          for(var i = 0 ; i<t.data.list.length ; i++){
             t.data.list[i]['percent'] = 0;
             t.data.list[i].percent = Math.round(t.data.list[i].sell_nums * 100 / t.data.list[i].all_nums)
          }
          console.log(t)
          that.setData({
            tolist:t.data.list
          })
       
        }
      },

    })
  },
  goods:function(e){
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/goods/goods?id=' + id,
    })
  }
  
})